package practice.p1;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        Scanner scanner=new Scanner(System.in);
        //1.创建连接对象
        Socket socket=new Socket("localhost",10086);
        //2.获取输出流对象
        OutputStream outputStream = socket.getOutputStream();
        //3.写出数据
        while (true) {
            System.out.println("输入发送的消息");
            String str = scanner.next();
            if ("88".equals(str)){
                System.out.println("再见");
                break;
            }
            outputStream.write(str.getBytes());
        }
        //4.关闭流
        socket.close();
    }
}
